<template>
  <div class="order-header">
    <div class="header">
      <div class="num-ordering tol">
        <p><span>{{num}}</span>人</p>
        <p>今日订餐人数</p>
      </div>
      <div class="price tol">
        <p><span>{{totalPrice}}</span>元</p>
        <p>今日订餐总价</p>
      </div>
      <div class="num-people tol">
        <p><span>{{num*3}}</span>人</p>
        <p>本周订餐人数</p>
      </div>
      <div class="total-price">
        <p><span>{{totalPrice*2}}</span>元</p>
        <p>本周订餐总价</p>
      </div>
    </div>
    <div class="data">{{date}}</div>
    <div class="meal-management" @click="goRecord">订单记录</div>
  </div>
</template>

<script setup>
import mitt from '../../utils/eventBus'
import {useRouter} from 'vue-router'
import {ref,reactive} from 'vue'
let router = useRouter();
let goRecord = ()=>{
  router.push('/index/record');
}
// 接收值
let num = ref()
mitt.on('personNum',(item)=>{
  num.value = item;
})
let totalPrice = ref()
mitt.on('totalPrice',(item)=>{
  totalPrice.value = item;
})
// 时间
let date = ref(new Date().toLocaleDateString());
</script>

<style scoped lang="scss">
.order-header {
  margin: 40px 0 0 20px;
  background: rgba(228, 228, 228, 0.8);;
  height: 172px;
  display: flex;
  position: relative;
  .header {
    width: 100%;
    display: flex;
    justify-content:space-evenly;
    text-align: center;
    color: #666666;
    align-items: center;
    p {
      font-weight: bold;
    }
    p:nth-child(1) {
      font-size: 14px;

      padding-bottom: 20px;
      span {
        font-size: 28px;
      }
    }
    p:nth-child(2) {
      font-size: 16px;
    }
    .tol{
        position: relative;
    }
    .tol:before{
        content: "";
        width: 2px;
        height: 48px;
        background: url('../../assets/shu.png');
        position: absolute;
        top: 20px;
        right: -90px;
    }
  }
  .data{
    position: absolute;
    width: 141px;
    height: 41px;
    background: rgba(204, 0, 0, 0.807843137254902);
    color: #fff;
    text-align: center;
    line-height:41px;
    font-weight: bold;
    top: -20px;
    left: 20px;
    border-radius: 5px;
  }
  .meal-management {
    position: absolute;
    right: 50px;
    top: 10px;
    font-size: 14px;
    color: #666666;
  }
  .meal-management:hover {
    color: darkgray;
    cursor: pointer;
  }
}
</style>